const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path')

module.export = {
    mode:'none',
    entry:{
        index:'./src/index.js'
    }, 
    output:{
        path:path.join(__dirname,'./build'),
        filename:'bundle[hash:5].js',
        environment:{
            arrowFunction:false
        }
    },
    devServer:{
        port:9090,
        proxy:{   
            '/api':{
                target: 'http://localhost:3000', 
            }
        }
    },
    module:{
        rules:[
            

            {
                test:/\.s[ac]ss$/,
                use:['style-loader','css-loader','sass-loader']
            },
            {
                test:/\.(png|jpe?g|gif|svg|webp)(\?.*)?$/,
                use:{
                    loader:'url-loader',
                    options: {
                        limit: 8000, 
                        name: 'img/[name].[hash:5].[ext]'
                    }
                }
            }
        ]
    },

    plugins:[
        new HtmlWebpackPlugin({
            template:'./src/index.html'
        }),
        new CleanWebpackPlugin(),
        new CopyWebpackPlugin({
            patterns:[
                // 把build目录中所有文件，拷贝到输入目录
                'build', 

            ]
           
        })
    ]

}